home *** CD-ROM | disk | FTP | other *** search
- Path: info.uah.edu!oreo!gbacon
- From: gbacon@oreo (Greg Bacon)
- Newsgroups: comp.lang.c
- Subject: Re: Help a fellow C programer
- Date: 13 Jan 1996 01:29:17 GMT
- Organization: The University of Alabama in Huntsville
- Message-ID: <4d71td$88a@info.uah.edu>
- References: <4d3t4q$ea6@klein.delphi.com>
- NNTP-Posting-Host: oreo.aspire.cs.uah.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Diane Barker (Barker@mci.newscorp.com) wrote:
- : Can any one tell me the C function/statment that is equal to the math
- : function ! (factorial).
-
- : Email me at: BARKER@MCI.NEWSCORP.COM if you can help
-
- : Mike Barker
-
- int factorial(unsigned int a)
- {
- if ((a == 0) || (a == 1))
- return 1;
- else
- return a * factorial(a-1);
- }
-
- That's a recursive version. a is unsigned since the factorial operation
- is only defined over [0, \infinity)
-
- Greg
- --
- Greg Bacon <gbacon@cs.uah.edu>
- University of Alabama in Huntsville
- CS Department Systems Support Team
-